<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.util.*"
         pageEncoding="UTF-8" %>
<%@ page language="java" import="com.opensymphony.xwork2.ActionContext" %>
<%@ page import="tree_util.Account" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    List<String> name = (ArrayList<String>) session.getAttribute("moniter");
%>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="edge"/>
    <meta name="author" content="Daliu"/>
    <meta name="keywords" content="长江上游珍稀特有鱼类保护信息管理系统、长江上游、珍稀特有鱼类、保护信息"/>
    <meta name="describe" content="长江上游珍稀特有鱼类保护信息管理系统"/>
    <title>长江上游珍稀特有鱼类保护信息管理系统</title>
    <link href="css/register.css" rel="stylesheet"/>
    <link href="css/main.css" rel="stylesheet"/>
    <style type="text/css">
        select {
            margin-left: 0px;
            height: 25px;
            width: 120px;
            border-radius: 5px;
            border-color: #8DEEEE;
        }

        .selectMoniter {
            width: 96%;
            text-align: left;
            margin: 10px auto;
        }

        .btn {
            display: inline-block;
            height: 27px;
            font-size: 13px;
        }

        .table {
            margin-bottom: 150px;
        }

        .table input {
            height: auto;
            margin-top: 3px;
        }

        .table label {
            display: inline-block;
            height: 20px;
        }

        .table td {
            margin: auto;

        }

    </style>

    <script type="text/javascript" src="js/jquery-1.12.3.min.js"></script>
    <script type="text/javascript">
        function check() {
            var int0 = parseInt($('input[name="monitsite"]:checked').val());
            var int1 = parseInt($('input[name="surface"]:checked').val());
            var int2 = parseInt($('input[name="line"]:checked').val());
            var int3 = parseInt($('input[name="Dot"]:checked').val());
            var int4 = parseInt($('input[name="water"]:checked').val());
            var int5 = parseInt($('input[name="tool"]:checked').val());
            var int6 = parseInt($('input[name="catches"]:checked').val());
            var int7 = parseInt($('input[name="fish"]:checked').val());
            var int8 = parseInt($('input[name="fishEgg"]:checked').val());
            var int9 = parseInt($('input[name="Sediment"]:checked').val());
            var int10 = parseInt($('input[name="benthos"]:checked').val());
            var int11 = parseInt($('input[name="phytoplankton"]:checked').val());
            var int12 = parseInt($('input[name="zooplanktonSpecies"]:checked').val());
            var int13 = parseInt($('input[name="phytoplanktonSpecies"]:checked').val());
            var int14 = parseInt($('input[name="benthosSpecies"]:checked').val());


            return int0 + int1 + int2 + int3 + int4 + int5 + int6 + int7 + int8 + int9 + int10 + int11 + int12 + int13 + int14 !== 0;

        }


        function getMoniter(selectGroup) {
            $.ajax({
                type: "get",
                async: true,
                url: "getMoniter.action",
                data: {
                    "group": selectGroup,
                },
                success: function (result) {
                    if (result === "error") {
                        alert("error");
                    }
                    else {
                        var monArray = result.split(",");
                        if (monArray.length === 0) {
                            alert("无Moniter " + result);
                        }
                        $("#targetMonier").empty();
                        for (var i = 0; i < monArray.length; i++) {
                            $("#targetMonier").append("<option value='" + monArray[i] + "'>" + monArray[i] + "</option>");
                        }

                    }

                }
            });
        }

        var selectGroup = "<%=name.get(0)%>";
        getMoniter(selectGroup);


        function gradeChange() {
            var selectGroup = $("#targetGroup option:selected").val();
            getMoniter(selectGroup);

        }


    </script>
</head>
<body>
<div class="article" id="article">
    <h3 class="useractive">&nbsp;&nbsp;数据申请</h3>
    <form action="dataRequest.action" method="post" enctype="multipart/form-data" onsubmit="return check()">
        <div class="selectMoniter">
            <strong>&nbsp&nbsp请选择 group:</strong>

            <select id="targetGroup" onchange="gradeChange()">
                <%
                    String thisName = ((Account) session.getAttribute("account")).getUsername();
                    String mon;
                    for (int i = 0; i < name.size(); i++) {
                        mon = name.get(i);
                        if (mon.equals(thisName)) continue;

                %>
                <option value="<%=mon%>"><%=mon%>
                </option>
                <%}%>
            </select>
            <strong>&nbsp&nbsp请选择 moniter:</strong>
            <select id="targetMonier" name="targetMonier">
            </select>

            <button class="btn btn-primary">提交申请</button>

        </div>
        <table class="table">
            <tr>
                <th>数据名</th>
                <th>是否查看</th>
            </tr>
            <tr>
                <td>监测点</td>
                <td><span>选择:  </span><label>是</label><input type="radio" value="1" name="monitsite"><label
                        style="height:20px;">否</label><input type="radio" value="0" checked="checked" name="monitsite">
                </td>
            </tr>
            <tr>
                <td>断面</td>
                <td><span>选择:  </span><label>是</label><input type="radio" value="1"
                                                             name="surface"><label>否</label><input type="radio"
                                                                                                   value="0"
                                                                                                   checked="checked"
                                                                                                   name="surface"></td>
            </tr>
            <tr>
                <td>浮游动物</td>
                <td><span>选择:  </span><label>是</label><input type="radio" value="1"
                                                             name="zooplankton"><label>否</label><input type="radio"
                                                                                                       value="0"
                                                                                                       checked="checked"
                                                                                                       name="zooplankton">
                </td>
            </tr>
            <tr>
                <td>浮游动物优势种</td>
                <td><span>选择:  </span><label>是</label><input type="radio" value="1"
                                                             name="zooplanktonSpecies"><label>否</label><input
                        type="radio" value="0" checked="checked" name="zooplanktonSpecies"></td>
            </tr>
            <tr>
                <td>浮游植物</td>
                <td><span>选择:  </span><label>是</label><input type="radio" value="1"
                                                             name="phytoplankton"><label>否</label><input type="radio"
                                                                                                         value="0"
                                                                                                         checked="checked"
                                                                                                         name="phytoplankton">
                </td>
            </tr>
            <tr>
                <td>浮游植物优势种</td>
                <td><span>选择:  </span><label>是</label><input type="radio" value="1"
                                                             name="phytoplanktonSpecies"><label>否</label><input
                        type="radio" value="0" checked="checked" name="phytoplanktonSpecies"></td>
            </tr>
            <tr>
                <td>底栖生物</td>
                <td><span>选择:  </span><label>是</label><input type="radio" value="1"
                                                             name="benthos"><label>否</label><input type="radio"
                                                                                                   value="0"
                                                                                                   checked="checked"
                                                                                                   name="benthos"></td>
            </tr>
            <tr>
                <td>底栖生物优势种</td>
                <td><span>选择:  </span><label>是</label><input type="radio" value="1"
                                                             name="benthosSpecies"><label>否</label><input type="radio"
                                                                                                          value="0"
                                                                                                          checked="checked"
                                                                                                          name="benthosSpecies">
                </td>
            </tr>
            <tr>
                <td>侧线</td>
                <td><span>选择:  </span><label>是</label><input type="radio" value="1" name="line"><label>否</label><input
                        type="radio" value="0" checked="checked" name="line"></td>
            </tr>
            <tr>
                <td>测点</td>
                <td><span>选择:  </span><label>是</label><input type="radio" value="1" name="Dot"><label>否</label><input
                        type="radio" value="0" checked="checked" name="Dot"></td>
            </tr>
            <tr>
                <td>采样水层</td>
                <td><span>选择:  </span><label>是</label><input type="radio" value="1" name="water"><label>否</label><input
                        type="radio" value="0" checked="checked" name="water"></td>
            </tr>
            <tr>
                <td>网具</td>
                <td><span>选择:  </span><label>是</label><input type="radio" value="1" name="tool"><label>否</label><input
                        type="radio" value="0" checked="checked" name="tool"></td>
            </tr>
            <tr>
                <td>渔获物</td>
                <td><span>选择:  </span><label>是</label><input type="radio" value="1"
                                                             name="catches"><label>否</label><input type="radio"
                                                                                                   value="0"
                                                                                                   checked="checked"
                                                                                                   name="catches"></td>
            </tr>
            <tr>
                <td>渔样本</td>
                <td><span>选择:  </span><label>是</label><input type="radio" value="1" name="fish"><label>否</label><input
                        type="radio" value="0" checked="checked" name="fish"></td>
            </tr>
            <tr>
                <td>卵样本</td>
                <td><span>选择:  </span><label>是</label><input type="radio" value="1"
                                                             name="fishEgg"><label>否</label><input type="radio"
                                                                                                   value="0"
                                                                                                   checked="checked"
                                                                                                   name="fishEgg"></td>
            </tr>
        </table>
    </form>
</div>
</body>
</html>